package leetcode.offer;

import leetcode.base.TreeNode;

/**
 * ClassName: Offer55I_MaxDepth
 * Description: leetcode-剑指offer 55 I 二叉树的深度
 * date: 2021-11-13 9:18
 *
 * @author liyifan
 */
public class Offer55I_MaxDepth {
    public int maxDepth(TreeNode root) {
        if (root == null)
            return 0;
        if (root.left == null && root.right == null)
            return 1;
        else
            return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }
}
